class ChartsController < ApplicationController
  def index
    @annotations = Annotation.find
  end

  def filter_select    
    @filter_choice = params[:filtertype]
    @docid = params[:docid]
    redirect_to "/charts/barbasic?docid=" + @docid + "&filtertype=" + @filter_choice
  end
  
  def areaspline
    annotation_amount = Array.new
    for i in 0..10
      @annotations = Annotation.find(:all, :conditions=>{:document_id => params[:docid], :points_array => [i]})
      annotation_amount << @annotations.size
    end

    @annotation_amt = annotation_amount
    render :layout => false
  #@annotations = Annotation.find_all_by_document_id(params[:docid])
  end


  def piebasic #not right, but will do for now.
  @annotations = Annotation.find(:all, :conditions=>{:document_id => params[:docid]}, :order => "created_at DESC")

   annotationobj = Document.find(params[:docid])
      @maleannotations = annotationobj.male_annotators
      @femaleannotations = annotationobj.female_annotators
   
   orientation_array = Array.new
        orientation_array << annotationobj.annotation_by_orientation("Straight").size
        orientation_array << annotationobj.annotation_by_orientation("Gay").size
        orientation_array << annotationobj.annotation_by_orientation("Lesbian").size
        orientation_array << annotationobj.annotation_by_orientation("Bisexual").size
        orientation_array << annotationobj.annotation_by_orientation("Transexual").size
        orientation_array << annotationobj.annotation_by_orientation("Other").size
        orientation_array << annotationobj.annotation_by_orientation("Prefer Not to Say").size
      @orientation_arr = orientation_array

    education_array = Array.new
        education_array << annotationobj.annotation_by_education("Elementary/Middle School").size
        education_array << annotationobj.annotation_by_education("High School").size
        education_array << annotationobj.annotation_by_education("Bachelors").size
        education_array << annotationobj.annotation_by_education("Masters").size
        education_array << annotationobj.annotation_by_education("Doctorate").size
        education_array << annotationobj.annotation_by_education("None").size
        education_array << annotationobj.annotation_by_education("Other").size
        education_array << annotationobj.annotation_by_education("Prefer Not to Say").size
      @education_arr = education_array

    race_array = Array.new
        race_array << annotationobj.annotation_by_race("Caucasian").size
        race_array << annotationobj.annotation_by_race("African-American").size
        race_array << annotationobj.annotation_by_race("Hispanic/Latin American").size
        race_array << annotationobj.annotation_by_race("Asian").size
        race_array << annotationobj.annotation_by_race("South-Asian").size
        race_array << annotationobj.annotation_by_race("Indegenous").size
        race_array << annotationobj.annotation_by_race("Other").size
        race_array << annotationobj.annotation_by_race("Prefer Not to Say").size
       @race_arr = race_array

     religion_array = Array.new
        religion_array << annotationobj.annotation_by_religion("Atheist").size
        religion_array << annotationobj.annotation_by_religion("Agnostic").size
        religion_array << annotationobj.annotation_by_religion("Christianity").size
        religion_array << annotationobj.annotation_by_religion("Judaism").size
        religion_array << annotationobj.annotation_by_religion("Hinduism").size
        religion_array << annotationobj.annotation_by_religion("Buddhism").size
        religion_array << annotationobj.annotation_by_religion("Islam").size
        religion_array << annotationobj.annotation_by_religion("None").size
        religion_array << annotationobj.annotation_by_religion("Other").size
       @religion_arr = religion_array

     political_array = Array.new
        political_array << annotationobj.annotation_by_political("Liberal").size
        political_array << annotationobj.annotation_by_political("Moderate").size
        political_array << annotationobj.annotation_by_political("Conservative").size
        political_array << annotationobj.annotation_by_political("Libertarian").size
        political_array << annotationobj.annotation_by_political("Other").size
        political_array << annotationobj.annotation_by_political("Prefer Not to Say").size 
       @political_arr = political_array

      occupation_array = Array.new
        occupation_array << annotationobj.annotation_by_occupation("Service").size
        occupation_array << annotationobj.annotation_by_occupation("Legal").size
        occupation_array << annotationobj.annotation_by_occupation("Student").size
        occupation_array << annotationobj.annotation_by_occupation("Computer/IT").size
        occupation_array << annotationobj.annotation_by_occupation("Engineering").size
        occupation_array << annotationobj.annotation_by_occupation("Health Care").size
        occupation_array << annotationobj.annotation_by_occupation("Writing").size
        occupation_array << annotationobj.annotation_by_occupation("Social Work").size
        occupation_array << annotationobj.annotation_by_occupation("Entertainment").size
        occupation_array << annotationobj.annotation_by_occupation("Other").size
        occupation_array << annotationobj.annotation_by_occupation("Unemployed").size
        occupation_array << annotationobj.annotation_by_occupation("Prefer Not to Say").size
    @occupation_arr = occupation_array
  #redirect_to :action => 'barbasic'
  render :layout => false
  end


  def barstacked
  render :layout => false
  end

  def barbasic
    @annotations = Annotation.find(:all, :conditions=>{:document_id => params[:docid]}, :order => "created_at DESC")

   annotationobj = Document.find(params[:docid])
      @maleannotations = annotationobj.male_annotators
      @femaleannotations = annotationobj.female_annotators
   
   orientation_array = Array.new
        orientation_array << annotationobj.annotation_by_orientation("Straight").size
        orientation_array << annotationobj.annotation_by_orientation("Gay").size
        orientation_array << annotationobj.annotation_by_orientation("Lesbian").size
        orientation_array << annotationobj.annotation_by_orientation("Bisexual").size
        orientation_array << annotationobj.annotation_by_orientation("Transexual").size
        orientation_array << annotationobj.annotation_by_orientation("Other").size
        orientation_array << annotationobj.annotation_by_orientation("Prefer Not to Say").size
      @orientation_arr = orientation_array

    education_array = Array.new
        education_array << annotationobj.annotation_by_education("Elementary/Middle School").size
        education_array << annotationobj.annotation_by_education("High School").size
        education_array << annotationobj.annotation_by_education("Bachelors").size
        education_array << annotationobj.annotation_by_education("Masters").size
        education_array << annotationobj.annotation_by_education("Doctorate").size
        education_array << annotationobj.annotation_by_education("None").size
        education_array << annotationobj.annotation_by_education("Other").size
        education_array << annotationobj.annotation_by_education("Prefer Not to Say").size
      @education_arr = education_array

    race_array = Array.new
        race_array << annotationobj.annotation_by_race("Caucasian").size
        race_array << annotationobj.annotation_by_race("African-American").size
        race_array << annotationobj.annotation_by_race("Hispanic/Latin American").size
        race_array << annotationobj.annotation_by_race("Asian").size
        race_array << annotationobj.annotation_by_race("South-Asian").size
        race_array << annotationobj.annotation_by_race("Indegenous").size
        race_array << annotationobj.annotation_by_race("Other").size
        race_array << annotationobj.annotation_by_race("Prefer Not to Say").size
       @race_arr = race_array

     religion_array = Array.new
        religion_array << annotationobj.annotation_by_religion("Atheist").size
        religion_array << annotationobj.annotation_by_religion("Agnostic").size
        religion_array << annotationobj.annotation_by_religion("Christianity").size
        religion_array << annotationobj.annotation_by_religion("Judaism").size
        religion_array << annotationobj.annotation_by_religion("Hinduism").size
        religion_array << annotationobj.annotation_by_religion("Buddhism").size
        religion_array << annotationobj.annotation_by_religion("Islam").size
        religion_array << annotationobj.annotation_by_religion("None").size
        religion_array << annotationobj.annotation_by_religion("Other").size
       @religion_arr = religion_array

     political_array = Array.new
        political_array << annotationobj.annotation_by_political("Liberal").size
        political_array << annotationobj.annotation_by_political("Moderate").size
        political_array << annotationobj.annotation_by_political("Conservative").size
        political_array << annotationobj.annotation_by_political("Libertarian").size
        political_array << annotationobj.annotation_by_political("Other").size
        political_array << annotationobj.annotation_by_political("Prefer Not to Say").size 
       @political_arr = political_array

      occupation_array = Array.new
        occupation_array << annotationobj.annotation_by_occupation("Service").size
        occupation_array << annotationobj.annotation_by_occupation("Legal").size
        occupation_array << annotationobj.annotation_by_occupation("Student").size
        occupation_array << annotationobj.annotation_by_occupation("Computer/IT").size
        occupation_array << annotationobj.annotation_by_occupation("Engineering").size
        occupation_array << annotationobj.annotation_by_occupation("Health Care").size
        occupation_array << annotationobj.annotation_by_occupation("Writing").size
        occupation_array << annotationobj.annotation_by_occupation("Social Work").size
        occupation_array << annotationobj.annotation_by_occupation("Entertainment").size
        occupation_array << annotationobj.annotation_by_occupation("Other").size
        occupation_array << annotationobj.annotation_by_occupation("Unemployed").size
        occupation_array << annotationobj.annotation_by_occupation("Prefer Not to Say").size
    @occupation_arr = occupation_array


      render :layout => false
  end

  def glancescatter
    @annotations = Annotation.find(:all, :order => "created_at DESC")

  end

  
end
